package com.aqiang.day0528_shop.sql

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import org.jetbrains.anko.db.ManagedSQLiteOpenHelper

class CarSql(var con:Context) : ManagedSQLiteOpenHelper(con,"car.db",null,1) {
    companion object {
        var nameDb:String = "car"
        private var carSql:CarSql? = null
        @Synchronized
        fun getInstance(ctx:Context):CarSql{
            if(carSql == null){
                carSql = CarSql(ctx)
            }
            return carSql!!
        }
    }
    override fun onCreate(db: SQLiteDatabase?) {
        db!!.execSQL("create table ${nameDb} (id Integer Primary key autoincrement,shoptitle varchar(100),tilte varchar(100),sellerid Long,inclu int,price float,img varchar(200))")
    }

    override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int, newVersion: Int) {
        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }
}